import {AdminInfo} from "../model/AdminInfo";

export class SpUtil {

  public static set(key: string, value: string): void {
    localStorage[key] = value;
  }

  public static get(key: string): string {
    return localStorage[key] || '';
  }

  public static setObj(key: string, value: any): void {
    localStorage[key] = JSON.stringify(value);
  }

  public static getObj(key: string): any {
    return JSON.parse(localStorage[key] || false);
  }

  public static remove(key: string): any {
    localStorage.removeItem(key);
  }

  public static getAdminInfo(): AdminInfo {
    return SpUtil.getObj('adminInfo');
  }

  public static setAdminInfo(adminInfo: AdminInfo): void {
    SpUtil.setObj('adminInfo', adminInfo);
  }
}
